<template>
	<view class="wanl-article">
		<view class="edgeInsetTop"></view>
		<!-- 进度条 -->
		<view class="load-progress" :class="loadProgress!=0?'show':'hide'">
			<view class="load-progress-bar bg-orange" :style="[{transform: 'translate3d(-' + (100-loadProgress) + '%, 0px, 0px)'}]"></view>
		</view>	
		
		<view class="margin-bj content">			
			<rich-text :nodes="detailsData.content"></rich-text>
		</view>
		
		<view v-if="detailsData.type1 == 'apply' && detailsData.reply == 2" style="margin-top: 40px;">
			<view style="width: 48%;float: left;text-align: right;color: green;font-weight: 600;" @tap="agree(1)">同意</view>
			<view style="width: 50%;float: left;text-align: center;color: red;font-weight: 600;" @tap="agree(1)">不同意</view>			
		</view>
		
		<view v-if="detailsData.type1 == 'agree'">
			<view style="width: 80%;float: left;text-align: right;color: green;font-weight: 600;" @tap="$wanlshop.auth('/pages/shop/apply/one/one?type=1')">申请入口</view>					
		</view>
		
		<view v-if="detailsData.type1 == 'apply' && (detailsData.reply == 1 || detailsData.reply == 0)" style="margin-top: 40px;">			
			<view style="width: 90%;float: left;text-align: center;color: orange;">{{detailsData.reply == 1?'你同意了该申请':'你拒绝了该申请'}} <text style="color: gray;">({{$wanlshop.timeToChat(detailsData.updatetime)}})</text></view>			
		</view>
	</view>
</template>

<script>
	import htmlParser from '@/common/html-parser';
	export default {
		data() {
			return {
				loadProgress: 0, //进度条
				detailsData: {}
			}
		},
		onLoad(option) {
			// 进度条
			this.LoadProgress();		
			this.loadData({id:option.id});
			this.$wanlshop.title(option.title);
		},
		methods: {
			// 异步加载
			async loadData(data) {
				await uni.request({
					url: '/wanlshop/notice/details',
					data: data,
					success: res => {
						//详情正则					
						this.detailsData = res.data;
						this.loadProgress = 90;
					}
				});
			},
			// 进度条
			LoadProgress() {
				this.loadProgress = this.loadProgress + 2;
				if (this.loadProgress < 100) {
					setTimeout(() => {
						this.LoadProgress();
					}, 100)
				} else {
					this.loadProgress = 0;
				}
			},
			agree(t){
				uni.request({
					url: '/wanlshop/notice/agree',
					data: {t:t,id:this.detailsData.id},
					success: res => {
						//详情正则					
						this.detailsData = res.data;
						this.loadProgress = 90;
					}
				});
			}
		}
	}
</script>

<style>
	.wanl-article .content{
		
	}
</style>
